{extend name="light-year/layout/master/detail" /}

{block name="title"}菜单管理{/block}
{block name="page-title"}菜单{/block}

{block name="content"}
    <input name="menu_id" class="form-control" type="hidden" value="{if $detail}{$detail->menu_id}{/if}" />
    <div class="form-group">
        <label><span class="text-danger">*</span> 父级栏目：</label>
        <div class="form-controls">
            <?php $parent_id = input('parent_id', 0);?>
            <select name="role_id" class="form-control" required>
                <option value="0">--默认顶级--</option>
                {if $menus}
                    {foreach $menus as $menu}
                        <option value="{$menu['menu_id']}"
                                {if $detail}
                                    {$menu['menu_id'] == $detail->parent_id ? 'selected' : ''}
                                {else /}
                                    {$menu['menu_id'] == $parent_id ? 'selected' : ''}
                                {/if}
                                > {$menu['menu_name']} </option>
                        {if !empty($menu['_child'])}
                            {foreach $menu['_child'] as $child}
                                <option value="{$child['menu_id']}"
                                        {if $detail}
                                            {$child['menu_id'] == $detail->parent_id ? 'selected' : ''}
                                        {else /}
                                            {$child['menu_id'] == $parent_id ? 'selected' : ''}
                                        {/if}
                                >├─{$child['menu_name']} </option>
                            {/foreach}
                        {/if}
                    {/foreach}
                {/if}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label><span class="text-danger">*</span> 菜单名称：</label>
        <input type="text" class="form-control" name="menu_name" value="{if $detail}{$detail->menu_name}{/if}" placeholder="输入菜单名称" required="" />
        <small class="help-block">
            <i class="mdi mdi-information"></i>
            唯一标识
        </small>
    </div>
    <div class="form-group">
        <label><span class="text-danger">*</span> 页面路由：</label>
        <input type="text" class="form-control" name="menu_url" value="{if $detail}{$detail->menu_url}{/if}" placeholder="输入页面路由"/>
        <small class="help-block">
            <i class="mdi mdi-information"></i>
            访问路由
        </small>
    </div>
    <div class="form-group">
        <label><span class="text-danger">*</span> 图标：</label>
        <input type="text" class="form-control" name="menu_icon" value="{if $detail}{$detail->menu_icon}{/if}" placeholder="输入图标"/>
        <small class="help-block">
            <i class="mdi mdi-information"></i>
            图标
        </small>
    </div>
    <div class="form-group">
        <label><span class="text-danger">*</span> 排序：</label>
        <input type="number" class="form-control" name="menu_sort" value="{if $detail}{$detail->menu_sort}{else/}1{/if}"/>
        <small class="help-block">
            <i class="mdi mdi-information"></i>
            从小到大，升序
        </small>
    </div>
    <div class="form-group">
        <label>
            是否左侧展示：
        </label>
        <div class="clearfix">
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_left" value="1" {if (empty($detail) || $detail->is_left === 1) }checked{/if}><span>是</span>
            </label>
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_left" value="0" {if (empty($detail) || $detail->is_left === 0) }checked{/if}><span>否</span>
            </label>
        </div>
    </div>
    <div class="form-group">
        <label>
            是否启用：
        </label>
        <div class="clearfix">
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_check" value="1" {if (empty($detail) || $detail->is_check === 1) }checked{/if}><span>启用</span>
            </label>
            <label class="lyear-radio radio-inline radio-primary">
                <input type="radio" name="is_check" value="0" {if (empty($detail) || $detail->is_check === 0) }checked{/if}><span>禁用</span>
            </label>
        </div>
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-primary ajax-post" target-form="add-form">确 定</button>
        <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
    </div>
{/block}